<!DOCTYPE html>
<html lang="zh-CN" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title th:text="${course.id != null ? '编辑课程' : '添加课程'} + ' - 学生成绩管理系统'">编辑课程 - 学生成绩管理系统</title>
    <link rel="stylesheet" href="/css/layui.css">
    <link rel="stylesheet" href="/css/dp07.css">
</head>
<body>
<div class="layui-container">
    <div class="layui-row layui-margin-top20">
        <div class="layui-col-md6">
            <h2 th:text="${course.id != null ? '编辑课程' : '添加课程'}">编辑课程</h2>
        </div>
        <div class="layui-col-md6" style="text-align: right;">
            <a href="/course/list" class="layui-btn layui-btn-primary">返回列表</a>
        </div>
    </div>
    
    <div class="layui-card layui-margin-top20">
        <div class="layui-card-body">
            <form class="layui-form" th:action="@{/course/save}" method="post" th:object="${course}">
                <input type="hidden" th:field="*{id}">
                
                <div class="layui-form-item">
                    <label class="layui-form-label">课程编号</label>
                    <div class="layui-input-block">
                        <input type="text" th:field="*{courseNo}" required lay-verify="required" placeholder="请输入课程编号" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">课程名称</label>
                    <div class="layui-input-block">
                        <input type="text" th:field="*{courseName}" required lay-verify="required" placeholder="请输入课程名称" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">学分</label>
                    <div class="layui-input-block">
                        <input type="number" th:field="*{credit}" required lay-verify="required" placeholder="请输入学分" autocomplete="off" class="layui-input" step="0.5" min="0" max="10">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">课程类型</label>
                    <div class="layui-input-block">
                        <input type="radio" th:field="*{courseType}" name="courseType" value="1" title="必修课">
                        <input type="radio" th:field="*{courseType}" name="courseType" value="2" title="选修课">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">任课教师</label>
                    <div class="layui-input-block">
                        <input type="text" th:field="*{teacher}" placeholder="请输入任课教师" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <label class="layui-form-label">开课学期</label>
                    <div class="layui-input-block">
                        <input type="text" th:field="*{semester}" placeholder="例如：2023-2024-1" autocomplete="off" class="layui-input">
                    </div>
                </div>
                
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit>保存</button>
                        <a href="/course/list" class="layui-btn layui-btn-primary">取消</a>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>

<script src="/js/jquery-3.7.1.min.js"></script>
<script src="/js/layui.js"></script>
<script>
    layui.use(['layer', 'element', 'form'], function(){
        var layer = layui.layer;
        var element = layui.element;
        var form = layui.form;
        
        // 解决Thymeleaf与Layui表单元素冲突问题
        setTimeout(function(){
            form.render(); // 重新渲染表单元素
        }, 100);
    });
</script>
</body>
</html> 